def selectionSort(arr):
    n = len(arr)
    count = 0
    for i in range(n - 1):
        minIndex = i
        for j in range(i + 1, n):
            count += 1
            if arr[j] < arr[minIndex]:
                minIndex = j
        if minIndex!= i:
            arr[i], arr[minIndex] = arr[minIndex], arr[i]
    print(f"函数运行次数: {count}")
    return arr

arr = [5, 3, 6, 2, 10, 14, 19, 15, 7, 8, 9, 1, 4, 11, 13, 12, 16, 17, 18]
sorted_arr = selectionSort(arr)
print(sorted_arr)